{-# OPTIONS -XExistentialQuantification -XFlexibleContexts -XTypeFamilies #-}

module Sim.ObsObject (
   ObsObject(..),
   CanBePixObject(..),
 ) where

import Sim.PixObject    ( PixObject(..), PixObsObject(..), PointSource(..), EllipseSource(..) )
import Sim.Star         ( Star(..) )
import Sim.PhysTypes

--import Data.VectorSpace ( (*^) )

type MagConvertor = SpType -> Magnitude -> PhotonFlux
type SedConvertor = SpType -> EnergyDist

-- Тип-контейнер для наблюдаемых объектов, которые могут быть представлены
-- как пикселизуемые объекты.

data ObsObject = forall a . CanBePixObject a => ObsObject a

class PixObject (T o) => CanBePixObject o where
   type T o :: *

   toPixObject :: Exposure -> MagConvertor -> SedConvertor -> o -> T o

instance CanBePixObject ObsObject where
   type T ObsObject = PixObsObject

   toPixObject e mc ec (ObsObject o) = PixObsObject $ toPixObject e mc ec o

instance CanBePixObject Star where
   type T Star = PointSource

   toPixObject et mc ec (Star _ st m xy) = PointSource (ec st) (et * mc st m) xy